﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SharpGL;
using KinectWindowLib;
using KinectWindows.Windows;
using System.Threading;
using KinectWindows;
using SharpGL.SceneGraph.Primitives;
using SharpGL.SceneGraph;
using SharpGL.SceneGraph.Quadrics;

namespace SharpGLWinformsApplication1
{
    /// <summary>
    /// The main form class.
    /// </summary>
    public partial class SharpGLForm : Form
    {

        /// <summary>
        /// Initializes a new instance of the <see cref="SharpGLForm"/> class.
        /// </summary>
        public SharpGLForm()
        {
            InitializeComponent();
            
        }

        

        void openGLControl_OpenGLDraw(object sender, SharpGL.RenderEventArgs args)
        {
            OpenGL gl = openGLControl.OpenGL;
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
           
            Display.DefaultGC().FillRectangle(-1, 1, 2, 2, KinectWindowLib.Color.White);
            Display.DefaultGC().DrawRectangle(-1, 1, 2, 2, KinectWindowLib.Color.Blue);
            Display.DefaultGC().FillRectangle(0, 0, 2, 2, KinectWindowLib.Color.White);
            Display.DefaultGC().DrawRectangle(0, 0, 2, 2, KinectWindowLib.Color.Blue);
           
        }
        /// <summary>
        /// Handles the OpenGLInitialized event of the openGLControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void openGLControl_OpenGLInitialized(object sender, EventArgs e)
        {
            OpenGL gl = openGLControl.OpenGL;
            Display.AddScreen(new KinectWindowLib.Screen(gl));
           // new Thread(new ThreadStart(WindowManager.WindowManagerLooper.Start)).Start();
        }

        /// <summary>
        /// Handles the Resized event of the openGLControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void openGLControl_Resized(object sender, EventArgs e)
        {
            OpenGL gl = openGLControl.OpenGL;
            Display.DefaultGC().RefreshGC(Width,Height);
          
           
          
        }

      

       
    }
}
